var path = require('path');
var ROOT_PATH = path.resolve(__dirname);
var nodeModules = {};
var fs = require("fs");

var nodeModules = {};

fs.readdirSync('node_modules')
	.filter(function (x) {
		return ['.bin'].indexOf(x) === -1;
	})
	.forEach(function (mod) {
		nodeModules[mod] = 'commonjs ' + mod;
	});
fs.readdirSync('src')
	.forEach(function (mod) {
		debugger
	});

nodeModules['../../common/api'] = '/common/api';
nodeModules['../../common/common'] = 'WeApp';
nodeModules['../../etc/config'] = '/etc/config';

module.exports = {
	entry: {
		'pages/classify/index': './src/pages/classify/index.ts',
		'pages/index/index': './src/pages/index/index.ts',
		'pages/logs/index': './src/pages/logs/index.ts',
		'pages/logs/logs.wxss': './src/pages/logs/logs.wxss'
	},
	output: {
		path: path.resolve(__dirname, './dist1'),
		filename: '[name].js',
		libraryTarget: "umd"
	},
	target: 'node',
	externals: nodeModules,
	context: __dirname,
	node: {
		__filename: false,
		__dirname: false
	},
	module: {
		loaders: [{
			test: /\.ts$/,
			exclude: [path.resolve(__dirname, "./res")],
			loader: 'ts-loader'
		}, {
			test: /\.json$/,
			loader: 'json-loader'
		}]
	},
	resolve: {
		extensions: ['.webpack.js', '.web.js', '.ts', '.js']
	},
}